package com.hzit;

import com.hzit.config.MyConfig;
import com.hzit.pojo.Pet;
import com.hzit.pojo.User;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Conditional;


/**
 * 类名：
 * 作者：WF
 * 功能：
 */
@SpringBootApplication
public class SpringBootApplication04 {
	public static void main(String[] args) {
		ConfigurableApplicationContext run = SpringApplication.run(SpringBootApplication04.class);
		// String[] beanDefinitionNames = run.getBeanDefinitionNames();
		// for (String beanDefinitionName : beanDefinitionNames) {
		// 	System.out.println(beanDefinitionName);
		// }
		// User user1 = run.getBean(User.class);
		// System.out.println("user1 = " + user1);
		MyConfig config = run.getBean(MyConfig.class);
		User user01 = config.user01();
		User user02 = config.user01();
		System.out.println("user01 = " + user01);
		System.out.println("user02 = " + user02);

		Pet pet01 = config.pet01();
		Pet pet02 = config.pet01();
		System.out.println("pet01 = " + pet01);
		System.out.println("pet02 = " + pet02);

		user01.setPet(pet01);
		user02.setPet(pet02);

	}
}
